from django.shortcuts import render
from app01 import models
from django.http import JsonResponse
from django.contrib import auth


# Create your views here.
def login(request):
    if request.method == 'GET':
        # 返回登陆界面
        return render(request, 'login.html', locals())

    # 获取用户输入的用户名和密码，然后；利用orm操作数据
    username = request.POST.get('username')
    password = request.POST.get('password')
    print(username, password)
    exist = models.User.objects.filter(username=username, password=password).exists()
    if exist:
        return render(request, 'xin.html', locals())
    return render(request, 'login.html', locals())


def photo_wall(request):
    return render(request, 'zhaopian.html')


def birthday_cake(request):
    return render(request, 'dangao.html')


def index(request):
    return render(request, 'index.html')


def love(request):
    if request.method == 'POST':
        data = request.POST.get('user')
        if data == '王桃爱竺新景':
            return render(request, 'zhu.html')
    return render(request, 'love.html')
